home *** CD-ROM | disk | FTP | other *** search
- Path: doc.ic.ac.uk!not-for-mail
- From: mdf@doc.ic.ac.uk (Martin Frost)
- Newsgroups: comp.sys.amiga.programmer
- Subject: Re: ..
- Date: 23 Feb 1996 16:37:19 -0000
- Organization: Dept. of Computing, Imperial College, University of London, UK.
- Distribution: world
- Message-ID: <4gkqfv$i7c@oak44.doc.ic.ac.uk>
- References: <0099DD37.C8BBBFBC@netins.net> <4g9g78$eri@btmpjg.god.bel.alcatel.be>
- Reply-To: mdf@doc.ic.ac.uk (Martin Frost)
- NNTP-Posting-Host: oak44.doc.ic.ac.uk
- X-Newsreader: mxrn 6.18-23
-
-
- In article <4g9g78$eri@btmpjg.god.bel.alcatel.be>, barnhoorn@nlev00 () writes:
- >In article <0099DD37.C8BBBFBC@netins.net>, tempest@netins.net writes:
- >|> If I wanted to make a progress bar for like loading a file.. showing
- >|> the bar slowely moving across the box (filling up the percentage done).
- >|> and perhaps print the percentage in the middle of this box, how would
- >|> I go about doing it? Any one have some example code or info on how
- >|> I could do it.. thanks..
-
- [code showing how to draw the bar deleted]
-
- You need to combine this bar code with splitting up your read into blocks,
- and update the bar after each read, as there is no way to determine how
- far the read has got otherwise.
-
- like this:
-
- #define EACH_READ_LEN 50000
- #define LAST_READ_LEN 70000
-
- /* return value same as Read() */
- LONG ProgressRead(BPTR File, APTR Buffer, ULONG Length)
- {
- ULONG Progress;
- LONG NumRead;
- DrawBar(0, Length); /* draw empty bar */
-
- Progress = 0;
- do
- {
- NumRead = Read(File, Buffer, EACH_READ_LEN);
- if(ReadVal < 0) return(-1); /* error */
- Progress += ReadVal;
- DrawBar(Progress,Length);
- }
- while(ReadVal > 0);
-
- return(Progress);
- }
-
- This assumes a routine DrawBar(curr, max) which draws a bar for curr bytes
- completed out of max.
-
- Martin
-